package engine.math
{
	public class RxPerlinNoise
	{
		private var m_permutationTable:Vector.<uint>;
		private var m_grad:Vector.<Number>;
		private static const s_gradients2D:Vector.<Number> = new Vector.<Number>([0, 1, 0, -1, 1, 0, -1, 0]);
		private static const s_gradients3D:Vector.<Number> = new Vector.<Number>([0, 1, 1, 0, -1, 1, 0, 1, -1, 0, -1, -1, 1, 0, 1, -1, 0, 1, 1, 0, -1, -1, 0, -1, 1, 1, 0, -1, 1, 0, 1, -1, 0, -1, -1, 0, 1, 1, 0, -1, 1, 0, 0, -1, 1, 0, -1, -1]);
				
		public function RxPerlinNoise()
		{
			var i:int = 0;
			var len:uint = 0;
			var table:uint = 0;
			var arr:Vector.<uint> = new Vector.<uint>(256, false);
			i = 0;
			while (i < 256)
			{
				
				arr[i] = i;
				i++;
			}
			this.m_permutationTable = new Vector.<uint>(256, true);
			i = 0;
			while (i < 256)
			{
				
				len = uint(arr.length * Math.random());
				table = arr[len];
				this.m_permutationTable[i] = table;
				arr[len] = arr[(arr.length - 1)];
				arr.length = arr.length - 1;
				i++;
			}
			
			this.m_grad = new Vector.<Number>(8, true);
		}
	}
}